/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.cggveritas.crewintranet.jms.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author Alassane
 */
@Entity
@Table(name = "cv_equipedepartement")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CvEquipedepartement.findAll", query = "SELECT c FROM CvEquipedepartement c"),
    @NamedQuery(name = "CvEquipedepartement.findByIdequipedepartement", query = "SELECT c FROM CvEquipedepartement c WHERE c.idequipedepartement = :idequipedepartement"),
    @NamedQuery(name = "CvEquipedepartement.findByEquipe", query = "SELECT c FROM CvEquipedepartement c WHERE c.equipe = :equipe")})
public class CvEquipedepartement implements Serializable {
    
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idequipedepartement")
    private Integer idequipedepartement;
    @Basic(optional = true)
    @Column(name = "equipe")
    private String equipe;
    @JoinColumn(name = "iddepartement", referencedColumnName = "iddepartement")
    @ManyToOne(fetch = FetchType.EAGER)
    private CvListedepartement iddepartement;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cvEquipedepartementIdequipedepartement", fetch = FetchType.LAZY)
    private List<CvAffectation> cvAffectationList;
    @OneToMany(mappedBy = "equipe", fetch = FetchType.LAZY)
    private List<CvListebesoin> cvListebesoinList;
    
    public CvEquipedepartement() {
    }

    public CvEquipedepartement(Integer idequipedepartement) {
        this.idequipedepartement = idequipedepartement;
    }

    public CvEquipedepartement(Integer idequipedepartement, String equipe) {
        this.idequipedepartement = idequipedepartement;
        this.equipe = equipe;
    }

    public Integer getIdequipedepartement() {
        return idequipedepartement;
    }

    public void setIdequipedepartement(Integer idequipedepartement) {
        this.idequipedepartement = idequipedepartement;
    }

    public String getEquipe() {
        return equipe;
    }

    public void setEquipe(String equipe) {
        this.equipe = equipe;
    }

    public CvListedepartement getIddepartement() {
        return iddepartement;
    }

    public void setIddepartement(CvListedepartement iddepartement) {
        this.iddepartement = iddepartement;
    }

    @XmlTransient
    @JsonIgnore
    public List<CvAffectation> getCvAffectationList() {
        return cvAffectationList;
    }

    public void setCvAffectationList(List<CvAffectation> cvAffectationList) {
        this.cvAffectationList = cvAffectationList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idequipedepartement != null ? idequipedepartement.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CvEquipedepartement)) {
            return false;
        }
        CvEquipedepartement other = (CvEquipedepartement) object;
        if ((this.idequipedepartement == null && other.idequipedepartement != null) || (this.idequipedepartement != null && !this.idequipedepartement.equals(other.idequipedepartement))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.cggveritas.crewintranet.jms.entities.CvEquipedepartement[ idequipedepartement=" + idequipedepartement + " ]";
    }

    @XmlTransient
    @JsonIgnore
    public List<CvListebesoin> getCvListebesoinList() {
        return cvListebesoinList;
    }

    public void setCvListebesoinList(List<CvListebesoin> cvListebesoinList) {
        this.cvListebesoinList = cvListebesoinList;
    }
    
}
